package com.boang.encode;

import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;

/*
  @author: 13813
  @date: 2024/12/12 15:38
*/
public class Encode {
    public static void main(String[] args) throws UnsupportedEncodingException {
        String str1 = "年";

        //编码
        byte[] bytes = str1.getBytes("utf-8");

        // utf-8 -27 -71 -76
        for (int i = 0; i < bytes.length; i++) {
            System.out.println(bytes[i]);
        }

        // -27 -71 -76
        byte[] bt = {-27, -71, -76};

        //解码
        String str2 = new String(bt, "GBK");
        System.out.println(str2);
    }
}
